package yangliu.controller;

import yangliu.entity.BjEntity;
import yangliu.entity.Page;
import yangliu.entity.PageUtils;
import yangliu.entity.YangLiuEntity;
import yangliu.service.YangLiuService;

import javax.annotation.Resource;
import java.util.List;

public class YangLiuController {
    Page page = null;
    String name = null;
    YangLiuEntity yangliu=null;
    Integer pageNo = null;
    String flag="0";
    List<BjEntity> bj=null;
    @Resource
    YangLiuService ylservice;
    public String queryPage(){
        //总条数
        int totalCount = ylservice.queryCount(name);
        //实现一个分页查询功能,计算
        page =  PageUtils.getPage(5,totalCount,pageNo);

        List<YangLiuEntity> list =ylservice.queryPage(page,name);
        page.setData(list);
        System.out.println(list);
        System.out.println(page);

        return "queryPage";
    }
    public String save(){
        ylservice.save(yangliu);
        flag = "1";
        return "save";
    }
    public String edit(){
        yangliu=ylservice.edit(yangliu);
        return "edit";
    }
    public String del(){
        ylservice.del(yangliu);
        flag = "1";
        return "del";
    }
    public String bj(){
        bj=ylservice.bj();
        return "bj";
    }
    //@Resource @Autowired 作用相同 去spring容器中到bean实例
    //@Service @Component 向spring 容器中放入bean（类的对象）实例

    public Page getPage() {
        return page;
    }

    public void setPage(Page page) {
        this.page = page;
    }

    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        this.pageNo = pageNo;
    }

    public YangLiuEntity getYangliu() {
        return yangliu;
    }

    public void setYangliu(YangLiuEntity yangliu) {
        this.yangliu = yangliu;
    }

    public String getFlag() {
        return flag;
    }

    public void setFlag(String flag) {
        this.flag = flag;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<BjEntity> getBj() {
        return bj;
    }

    public void setBj(List<BjEntity> bj) {
        this.bj = bj;
    }
}
